<?php


namespace Trawind\Basics\Traits;


use Trawind\Basics\Enums\BusinessCode;
use Trawind\Helpers\ResponseHelper;
use Illuminate\Http\JsonResponse;

trait ResponseFormat
{

    /**
     * @param $data
     * @param int $code
     * @param string|null $message
     * @return JsonResponse
     */
    protected function response($data, int $code = BusinessCode::REQUEST_OK, ?string $message = null): JsonResponse
    {
        return ResponseHelper::format($data, $code, $message);
    }
}
